#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "serialmanager.h"
#include "modbusrtu.h"
#include "logmanager.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    void initMainWindow();
    void initSignalSlot();

private slots:
    void onConnectButtonClicked();
    void onReadButtonClicked();
    void onWriteButtonClicked();
    void onDeleteButtonClicked();
    void onExportButtonClicked();
    void updateConnectionStatus(bool connected, const QDateTime &timestamp);
    void handleModbusResponse(const QString &response);
    void handleModbusError(const QString &error);

private:
    Ui::MainWindow *ui_;
    SerialManager *serialManager_;
    ModbusRTU *modbusRTU_;
    LogManager *logManager_;
    bool isConnected_ = false;
};
#endif // MAINWINDOW_H
